package com.company.genealogy.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.company.genealogy.common.result.ApiResponse;
import com.company.genealogy.web.entity.SysLog;
import com.company.genealogy.web.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.company.genealogy.common.constant.ApiCodeEnum;

@RestController
@RequestMapping("/api/v1/syslog")
public class SysLogController {
    
    @Autowired
    private SysLogService sysLogService;
    
    // 分页查询系统日志
    @GetMapping
    public ApiResponse<IPage<SysLog>> list(@RequestParam(defaultValue = "1") int page,
                                           @RequestParam(defaultValue = "10") int size) {
        IPage<SysLog> result = sysLogService.page(new Page<>(page, size));
        return ApiResponse.success(ApiCodeEnum.SUCCESS, result);
    }
    
    // 日志详情
    @GetMapping("/{id}")
    public ApiResponse<SysLog> detail(@PathVariable Long id) {
        SysLog log = sysLogService.getById(id);
        return ApiResponse.success(ApiCodeEnum.SUCCESS, log);
    }
} 